<template>
    <van-icon @click='starFunc' v-if="is_collected" :class="{star:is_collected==true}" color="#777" name="star-o"/>
    <van-icon @click='starFunc' v-else color="#777" name="star-o"/>
</template>
           
<script>
import {addCollect_api,deleteCollect_api}  from  '@/api/article.js'
export default {
    props:['artId','is_collected'],
  data() {
    return {
    //   starFlag: true
    }
  },
  methods:{
      async starFunc(){

          if(this.is_collected){
              //  取消收藏
            const {data:res}=await deleteCollect_api(this.artId)

          }else{
              //  收藏
              const {data:res}=await addCollect_api(this.artId)
          }
        //this.is_collected=!this.is_collected
        this.$emit('coll',!this.is_collected)

      }
  }
}
</script>
<style scoped lang='less'>
.star {
  background: orange!important;
}
</style>